/*--------------------------------------------------------------------------
  Project::HEXAGON FLIGHT SIMULATOR
  Package::Input
  Class::Joystick
  File Joystick.h
  --------------------------------------------------------------------------
  * METHODS AND CLASS PARAMETERS


  --------------------------------------------------------------------------
  * FUNCTIONS DESCRIPTION
  
  --------------------------------------------------------------------------
  * COPYRIGHT

  --------------------------------------------------------------------------
  * INFO ABOUT AUTHOR AND VERSIONS
  Author:	Tino Giorgio	Data: 
  Rev1:			Data:

  --------------------------------------------------------------------------
  * E-MAIL & CONTACTS

  GIORGIO TINO:	tinoshi@libero.it
	           	shapeofangels@hotmail.com
	            giorgio.tino@studenti.polito.it

  --------------------------------------------------------------------------*/

#if !defined(JOYSTICK_H)
#define JOYSTICK_H

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <plib/ul.h>
#include <plib/js.h>
#include "Defines.h"

/* Defines */
/* PLIB will search for this device on number: (see the order in Start->Control Panel->Gamepads...) */
#define PLIB_JOYSTICK_NUMBER 0

// ONE HOT define for buttons
#define JOYSTICK_A 0x1
#define JOYSTICK_B 0x2
#define JOYSTICK_X 0x4
#define JOYSTICK_Y 0x8
#define JOYSTICK_L 0x10
#define JOYSTICK_R 0x20

// ONE HOT defines for direction
#define JOYSTICK_LEFT		0x1
#define JOYSTICK_RIGHT		0x2
#define JOYSTICK_UP			0x4
#define JOYSTICK_DOWN		0x8
#define JOYSTICK_H_CENTERED 0x10
#define JOYSTICK_V_CENTERED 0x20

class Joystick  
{
public:
	Joystick();
	Joystick(int n);
	virtual ~Joystick();
	void read();
	int isPressed(int button);
	int isDirection(int direction);
	int isWorking();
	float getAX(int n);

private:
	float *ax;
	int buttons;
	jsJoystick *js;
	int ok;
};

#endif // !defined(JOYSTICK_H)
